import axios from 'axios'

export function request(config) {
  const instance = axios.create({
    timeout: 60000,
    // 根据环境变更请求的api
    baseURL: process.env.VUE_APP_BASE_API
  })

  instance.interceptors.request.use(config => {
    return config;
  }, err => {
    console.log(err);
  })

  instance.interceptors.response.use(res => {
    return res.data;
  }, err => {
    console.log(err)
  })
  if(config.method == "post") {
    return instance.post(config.url, config.params)
  } else {
    return instance(config)
  }
}

